package com.ruoyi.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.IronCore;
import com.ruoyi.business.service.IIronCoreService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 定子查询Controller
 * 
 * @author ruoyi
 * @date 2025-03-19
 */
@RestController
@RequestMapping("/business/core")
public class IronCoreController extends BaseController
{
    @Autowired
    private IIronCoreService ironCoreService;

    /**
     * 查询定子查询列表
     */
    @PreAuthorize("@ss.hasPermi('business:core:list')")
    @GetMapping("/list")
    public TableDataInfo list(IronCore ironCore)
    {
        startPage();
        List<IronCore> list = ironCoreService.selectIronCoreList(ironCore);
        return getDataTable(list);
    }

    /**
     * 导出定子查询列表
     */
    @PreAuthorize("@ss.hasPermi('business:core:export')")
    @Log(title = "定子查询", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IronCore ironCore)
    {
        List<IronCore> list = ironCoreService.selectIronCoreList(ironCore);
        ExcelUtil<IronCore> util = new ExcelUtil<IronCore>(IronCore.class);
        util.exportExcel(response, list, "定子查询数据");
    }

    /**
     * 获取定子查询详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:core:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ironCoreService.selectIronCoreById(id));
    }

    /**
     * 新增定子查询
     */
    @PreAuthorize("@ss.hasPermi('business:core:add')")
    @Log(title = "定子查询", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IronCore ironCore)
    {
        return toAjax(ironCoreService.insertIronCore(ironCore));
    }

    /**
     * 修改定子查询
     */
    @PreAuthorize("@ss.hasPermi('business:core:edit')")
    @Log(title = "定子查询", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IronCore ironCore)
    {
        return toAjax(ironCoreService.updateIronCore(ironCore));
    }

    /**
     * 删除定子查询
     */
    @PreAuthorize("@ss.hasPermi('business:core:remove')")
    @Log(title = "定子查询", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ironCoreService.deleteIronCoreByIds(ids));
    }
}
